package com.douqu.game.core.config.card;

import com.douqu.game.core.e.E_Attribute;
import com.douqu.game.core.entity.GameObject;
import com.douqu.game.core.factory.ConstantFactory;
import com.douqu.game.core.util.LogUtils;

/**
 * @author wangzhenfei
 *         2017-11-28 16:03
 *         军团连锁配置
 */
public class LegionChainConfig extends GameObject {
    /**参数**/
    public int[] param;
    /**参数描述**/
    public String paramRemark;
    /**对话组别**/
    public String dialogue;
    /**提升攻击**/
    public int[] addAtk;
    /**提升防御**/
    public int[] addDef;
    /**提升生命**/
    public int[] addHp;
    /**提升战力**/
    public int[] addFc;


    @Override
    public boolean check()
    {
        return super.check();
    }

    public int getAtt(int attrId, int i)
    {
        if(i < 0)
        {
//            LogUtils.error("Param Error -> attrId:" + attrId + ",i:" + i);
            return 0;
        }

        int[] datas;
        if(E_Attribute.ATK.getCode() == attrId)
            datas = addAtk;
        else if(E_Attribute.DEF.getCode() == attrId)
            datas = addDef;
        else if(E_Attribute.HP.getCode() == attrId)
            datas = addHp;
        else
            return 0;

        if(i >= datas.length)
            return datas[datas.length-1];

        return datas[i];
    }

    @Override
    public boolean setVariable(String key, String value) {
        if("param".equals(key))
        {
            String[] strs = value.split(ConstantFactory.DIVISION);
            param = new int[strs.length];
            for(int i = 0 ; i < strs.length; i++){
                param[i] = Integer.parseInt(strs[i]);
            }
            return true;
        }else  if("addAtk".equals(key))
        {
            String[] strs = value.split(ConstantFactory.DIVISION);
            addAtk = new int[strs.length];
            for(int i = 0 ; i < strs.length; i++){
                addAtk[i] = Integer.parseInt(strs[i]);
            }
            return true;
        }else  if("addDef".equals(key))
        {
            String[] strs = value.split(ConstantFactory.DIVISION);
            addDef = new int[strs.length];
            for(int i = 0 ; i < strs.length; i++){
                addDef[i] = Integer.parseInt(strs[i]);
            }
            return true;
        }else  if("addHp".equals(key))
        {
            String[] strs = value.split(ConstantFactory.DIVISION);
            addHp = new int[strs.length];
            for(int i = 0 ; i < strs.length; i++){
                addHp[i] = Integer.parseInt(strs[i]);
            }
            return true;
        }else  if("addFc".equals(key))
        {
            String[] strs = value.split(ConstantFactory.DIVISION);
            addFc = new int[strs.length];
            for(int i = 0 ; i < strs.length; i++){
                addFc[i] = Integer.parseInt(strs[i]);
            }
            return true;
        }
        else
            return super.setVariable(key, value);
    }


}
